package org.karelun.gef.parts;

import org.eclipse.draw2d.BendpointConnectionRouter;
import org.eclipse.draw2d.BendpointLocator;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.PointList;

public class CombinationConnectionEditPart extends
		CustomAbstractConnectionEditPart {
	
	protected IFigure createFigure() {
		PolylineConnection conn = new PolylineConnection();
		conn.setConnectionRouter(new BendpointConnectionRouter());
		
		PolygonDecoration decoration = new PolygonDecoration();
		PointList decorationPointList = new PointList();
		decorationPointList.addPoint(0, 0);
		decorationPointList.addPoint(-1, 1);
		decorationPointList.addPoint(-2, 0);
		decorationPointList.addPoint(-1, -1);
		
		decoration.setTemplate(decorationPointList);
		
		conn.setSourceDecoration(decoration);
		conn.setTargetDecoration(new PolygonDecoration());
		conn.setLineWidth(2);
		
		Label label_start=new Label("   1..."); //$NON-NLS-1$
		BendpointLocator locator_start=new BendpointLocator(conn,0);
		locator_start.setRelativePosition(PositionConstants.NORTH_EAST);
		conn.add(label_start, locator_start);

		Label label_end=new Label("n   "); //$NON-NLS-1$
		BendpointLocator locator=new BendpointLocator(conn,1);
		locator.setRelativePosition(PositionConstants.NORTH_WEST);
		conn.add(label_end, locator);
		
		return conn;
	}
}